import tensorflow as tf
opt = tf.keras.optimizers.SGD(learning_rate=0.1)

var = tf.Variable(1.0)

loss = lambda: (var ** 2) / 2.0
opt.minimize(loss,[var]).numpy()
print(var.numpy())